<template>
  <div class="error-page not-found-page">
    <!-- 背景元素 -->
    <div class="ai-background">
      <div class="circuit-line line-1"></div>
      <div class="circuit-line line-2"></div>
      <div class="circuit-line line-3"></div>
      <div class="circuit-dot dot-1"></div>
      <div class="circuit-dot dot-2"></div>
      <div class="circuit-dot dot-3"></div>
      <div class="circuit-dot dot-4"></div>
      <div class="circuit-dot dot-5"></div>
    </div>
    
    <div class="content-container">
      <!-- 动态数字 -->
      <div class="error-code">
        <div class="digit">4</div>
        <div class="digit zero">
          <div class="ai-face">
            <div class="ai-eye left"></div>
            <div class="ai-eye right"></div>
            <div class="ai-mouth"></div>
          </div>
        </div>
        <div class="digit">4</div>
      </div>
      
      <!-- 错误说明 -->
      <h1 class="error-title">智能检测到页面未找到</h1>
      <p class="error-description">
        我们的AI助手无法在神经网络中定位您请求的页面。
        <span class="highlight">这可能是因为URL输入错误、页面已被移动或已不存在。</span>
      </p>
      
      <!-- 智能建议 -->
      <div class="ai-suggestion">
        <div class="suggestion-header">
          <i class="fas fa-robot"></i>
          <span>智能助手建议</span>
        </div>
        <div class="suggestion-content">
          <div class="typing-indicator">
            <span></span><span></span><span></span>
          </div>
          <p>我检测到您可能想要访问以下页面：</p>
          <div class="suggestion-links">
            <router-link to="/" class="suggestion-link">
              <i class="fas fa-home"></i> 返回首页
            </router-link>
            <router-link to="/question-bank" class="suggestion-link">
              <i class="fas fa-book"></i> 题库管理
            </router-link>
            <router-link to="/paper-index/paper-list" class="suggestion-link">
              <i class="fas fa-file-alt"></i> 试卷列表
            </router-link>
          </div>
        </div>
      </div>
      
      <!-- 返回按钮 -->
      <div class="action-buttons">
        <button class="btn-back" @click="goBack">
          <i class="fas fa-arrow-left"></i> 返回上一页
        </button>
        <router-link to="/" class="btn-home">
          <i class="fas fa-home"></i> 返回首页
        </router-link>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'NotFound',
  methods: {
    goBack() {
      this.$router.go(-1);
    }
  },
  mounted() {
    // 动画效果：模拟AI思考
    setTimeout(() => {
      const typingIndicator = document.querySelector('.typing-indicator');
      if (typingIndicator) {
        typingIndicator.style.display = 'none';
        
        document.querySelectorAll('.suggestion-content > p, .suggestion-links').forEach(el => {
          el.style.opacity = '1';
        });
      }
    }, 2000);
    
    // 眨眼动画
    setInterval(() => {
      const eyes = document.querySelectorAll('.ai-eye');
      eyes.forEach(eye => {
        eye.classList.add('blink');
        setTimeout(() => eye.classList.remove('blink'), 200);
      });
    }, 3000);
    
    // 电路动画
    document.querySelectorAll('.circuit-dot').forEach((dot, index) => {
      setTimeout(() => {
        dot.classList.add('active');
      }, index * 300);
    });
  }
}
</script>

<style lang="less" scoped>
@import "@/styles/variables.less";

.error-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background-color: #f9fafe;
  position: relative;
  padding: 2rem;
  overflow: hidden;
  font-family: 'Segoe UI', 'PingFang SC', -apple-system, BlinkMacSystemFont, sans-serif;
}

.ai-background {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 0;
  overflow: hidden;
  
  .circuit-line {
    position: absolute;
    background: linear-gradient(90deg, fade(@primary, 5%), fade(@primary, 15%));
    height: 2px;
    
    &.line-1 {
      top: 25%;
      left: 0;
      width: 100%;
      transform: translateY(-50%);
    }
    
    &.line-2 {
      top: 75%;
      left: 0;
      width: 100%;
      transform: translateY(-50%);
    }
    
    &.line-3 {
      top: 0;
      left: 50%;
      width: 2px;
      height: 100%;
      transform: translateX(-50%);
      background: linear-gradient(0deg, fade(@primary, 5%), fade(@primary, 15%));
    }
  }
  
  .circuit-dot {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: fade(@primary, 30%);
    box-shadow: 0 0 10px fade(@primary, 40%);
    opacity: 0;
    transition: opacity 0.5s ease;
    
    &.active {
      opacity: 1;
    }
    
    &.dot-1 { top: 25%; left: 25%; }
    &.dot-2 { top: 25%; left: 75%; }
    &.dot-3 { top: 75%; left: 25%; }
    &.dot-4 { top: 75%; left: 75%; }
    &.dot-5 { top: 50%; left: 50%; }
  }
}

.content-container {
  max-width: 800px;
  width: 100%;
  text-align: center;
  z-index: 1;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.7));
  padding: 3rem;
  border-radius: 20px;
  box-shadow: @shadow-lg;
  backdrop-filter: blur(10px);
  animation: fadeIn 0.8s ease;
}

.error-code {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  margin-bottom: 2rem;
  
  .digit {
    font-size: 8rem;
    font-weight: 800;
    color: @primary;
    line-height: 1;
    text-shadow: 2px 2px 0 @primary-light;
    position: relative;
    
    &.zero {
      width: 120px;
      height: 120px;
      background: linear-gradient(135deg, @primary, @secondary);
      border-radius: 50%;
      display: flex;
      justify-content: center;
      align-items: center;
      color: white;
      overflow: hidden;
      box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.2), 0 10px 20px rgba(0, 0, 0, 0.1);
      position: relative;
      
      .ai-face {
        width: 100%;
        height: 100%;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        position: relative;
        
        .ai-eye {
          width: 20px;
          height: 20px;
          background-color: white;
          border-radius: 50%;
          position: absolute;
          top: 35%;
          transition: all 0.2s ease;
          
          &.left {
            left: 30%;
          }
          
          &.right {
            right: 30%;
          }
          
          &.blink {
            transform: scaleY(0.2);
          }
        }
        
        .ai-mouth {
          width: 40px;
          height: 15px;
          background-color: white;
          position: absolute;
          bottom: 30%;
          border-radius: 0 0 20px 20px;
          clip-path: polygon(0 0, 100% 0, 80% 100%, 20% 100%);
          animation: mouth-move 5s infinite;
        }
      }
    }
  }
}

@keyframes mouth-move {
  0%, 100% { clip-path: polygon(0 0, 100% 0, 80% 100%, 20% 100%); }
  30% { clip-path: polygon(0 0, 100% 0, 90% 70%, 10% 70%); }
  60% { clip-path: polygon(10% 0, 90% 0, 100% 100%, 0% 100%); }
}

.error-title {
  font-size: 2rem;
  color: @gray-800;
  margin-bottom: 1rem;
  font-weight: 700;
}

.error-description {
  font-size: 1.1rem;
  color: @gray-600;
  margin-bottom: 2rem;
  line-height: 1.6;
  
  .highlight {
    font-weight: 500;
    color: @secondary;
    background: linear-gradient(90deg, fade(@primary, 10%), fade(@primary-light, 20%));
    padding: 0.2rem 0.5rem;
    border-radius: @radius-md;
    display: inline-block;
    margin-top: 0.5rem;
  }
}

.ai-suggestion {
  background: white;
  border-radius: @radius-lg;
  padding: 1.5rem;
  margin-bottom: 2rem;
  box-shadow: @shadow-md;
  text-align: left;
  border-left: 4px solid @primary;
  
  .suggestion-header {
    display: flex;
    align-items: center;
    margin-bottom: 1rem;
    color: @primary;
    font-weight: 600;
    
    i {
      margin-right: 0.75rem;
      font-size: 1.2rem;
    }
  }
  
  .suggestion-content {
    color: @gray-700;
    
    p, .suggestion-links {
      opacity: 0;
      transition: opacity 0.5s ease;
    }
    
    p {
      margin-bottom: 1rem;
    }
    
    .typing-indicator {
      display: flex;
      align-items: center;
      gap: 0.25rem;
      margin-bottom: 1rem;
      
      span {
        width: 8px;
        height: 8px;
        border-radius: 50%;
        background-color: @primary;
        display: inline-block;
        animation: typing 1s infinite;
        
        &:nth-child(2) {
          animation-delay: 0.2s;
        }
        
        &:nth-child(3) {
          animation-delay: 0.4s;
        }
      }
    }
    
    .suggestion-links {
      display: flex;
      flex-wrap: wrap;
      gap: 1rem;
      
      .suggestion-link {
        display: flex;
        align-items: center;
        padding: 0.75rem 1.25rem;
        background: @gray-100;
        color: @gray-800;
        border-radius: @radius-md;
        text-decoration: none;
        font-weight: 500;
        transition: all 0.3s ease;
        
        i {
          margin-right: 0.5rem;
          color: @primary;
        }
        
        &:hover {
          background: @primary-light;
          transform: translateY(-2px);
          box-shadow: @shadow-sm;
        }
      }
    }
  }
}

.action-buttons {
  display: flex;
  justify-content: center;
  gap: 1rem;
  
  .btn-back, .btn-home {
    padding: 0.75rem 1.5rem;
    border-radius: @radius-md;
    font-weight: 500;
    font-size: 1rem;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    text-decoration: none;
    cursor: pointer;
    
    i {
      margin-right: 0.5rem;
    }
  }
  
  .btn-back {
    background-color: @gray-200;
    color: @gray-800;
    border: none;
    
    &:hover {
      background-color: @gray-300;
    }
  }
  
  .btn-home {
    background-color: @primary;
    color: white;
    border: none;
    
    &:hover {
      background-color: darken(@primary, 10%);
      transform: translateY(-2px);
      box-shadow: @shadow-md;
    }
  }
}

@keyframes typing {
  0%, 100% { opacity: 0.3; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1); }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

// 响应式调整
@media (max-width: 768px) {
  .content-container {
    padding: 2rem 1.5rem;
  }
  
  .error-code .digit {
    font-size: 6rem;
    
    &.zero {
      width: 90px;
      height: 90px;
    }
  }
  
  .error-title {
    font-size: 1.5rem;
  }
  
  .ai-suggestion .suggestion-links {
    flex-direction: column;
    
    .suggestion-link {
      width: 100%;
      justify-content: center;
    }
  }
  
  .action-buttons {
    flex-direction: column;
    
    .btn-back, .btn-home {
      width: 100%;
      justify-content: center;
    }
  }
}
</style> 